<?php
/*
# ------------------------------------------------------------------------
# JA Job Board Package
# ------------------------------------------------------------------------
# Copyright (C) 2004-2010 JoomlArt.com. All Rights Reserved.
# @license GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
# Author: JoomlArt.com
# Websites: http://www.joomlart.com - http://www.joomlancers.com.
# ------------------------------------------------------------------------
*/

jimport( 'joomla.application.component.view' );

class JAJobBoardViewJAApplications extends JAView
{
    /**
     * Display the view
     */
    function display($tmpl = null){
        global $mainframe;
              
       $task = JRequest::getVar("task", '');
		switch ($task){
			case 'add':
			case 'edit':				
				JAJobBoardViewJAApplications::edit();
				break;			
			default:
				JAJobBoardViewJAApplications::show_list();
		}    
    	
        parent::display($tmpl);
  	}
    
  	function show_list()
  	{
  		global $mainframe, $jbconfig, $option;
  		// get data items
        $model = &$this->getModel();               
		$user = JFactory::getUser();              
        $limitstart = JRequest::getInt('limitstart', 0);
		$limit		= $mainframe->getUserStateFromRequest( $option.'.jaresumes.limit',		'limit',	$jbconfig['posts']->get('display_num', 20),	'int' );
		$where_more = '';
		
       	$items = $model->getItems($where_more, $limit, $limitstart);       	
       	
       	$fieldEditList = $model->getEditFieldList(' and f.frontend_hidden=0');
       	$fieldList = $model->getFieldList();
		
		$pagination = &$this->get('Pagination');       
        
        $lists = $this->_getViewLists($fieldEditList);        
        
        $ordering = true;      
        $this->assignRef('items', $items);
        $this->assignRef('pagination', $pagination);
        $this->assignRef('fieldlist', $fieldList);
        $this->assignRef('lists', $lists);
        $this->assignRef('ordering', $ordering );
                
  	}
  	
    
  	/**
  	* Display edit form
  	*/
  	function edit(){
  		require_once(JPATH_COMPONENT_ADMINISTRATOR.DS.'asset'.DS.'rendfield.php');
        $item = $this->get('Item');
        if($item->id)
            JRequest::setVar('job_id', $item->job_id);
            
        $job = $this->get('JobInfo');
        $resumes = $this->get('Resumes');
        $fieldList = $this->get('EditFieldList');
        $menuId = JRequest::getVar('menuId');
       
        $this->setLayout('jaform');
        $this->assignRef('item', $item);
        $this->assignRef('job', $job);
        $this->assignRef('resumes', $resumes);
        $this->assignRef('fieldlist', $fieldList);
        $this->assignRef('menuId', $menuId);
//        parent::display();
    }
    
    /**
      * Display view form
      */
    function show_application_details(){
        $Itemid = JRequest::getVar('Itemid');       
        $fromsearch = JRequest::getVar('fromsearch', 0);
        
        $item = $this->get('Item');
        JRequest::setVar('job_id', $item->job_id);
        JRequest::setVar('resume_id', $item->resume_id);
        
        $job = $this->get('JobInfo');
        $resumes = $this->get('Resumes');
        $fieldList = $this->get('ViewFieldList');
        
        $this->assignRef('item', $item);
        $this->assignRef('job', $job); 
        $this->assignRef('fieldlist', $fieldList);
        $this->assignRef('Itemid', $Itemid);
        $this->assignRef('fromsearch', $fromsearch);         
        parent::display();
    }
    
    
    
	function &_getViewLists(){
		global $mainframe;

		$db = &JFactory::getDBO();
        
        $filter_order		= $mainframe->getUserStateFromRequest( JBCOMNAME.".jobs.filter_order",		'filter_order',		'',	'cmd' );
		$filter_order_Dir	= $mainframe->getUserStateFromRequest( JBCOMNAME.".jobs.filter_order_Dir",	'filter_order_Dir',	'ASC',			'word' );
		
		// table ordering
		$lists['order_Dir']	= $filter_order_Dir;
		$lists['order']		= $filter_order;

		return $lists;
	}

	

}
?>